import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/task/main/models/plan_task.dart';
import 'package:leader_help/page/task/subs/question_detail/index.dart';
import 'package:leader_help/utils/component/component.dart';
import 'package:leader_help/utils/component/dialog/drop.dart';
import 'package:leader_help/utils/util.dart';

import 'cell_empty.dart';

class QuestionDetailTaskCell extends GetView<QuestionDetailController> {
  const QuestionDetailTaskCell({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<QuestionDetailController>(builder: (_) {
      var mod = controller.state.taskMod;
      return mod == null
          ? QuestionDetailEmptyView(
              actionTitle: controller.state.planMod == null ? null : '做安排',
              mod: UsuallyModel(
                name: '暂无任务安排，请先选定目标和方案',
                url: 'task_bg.png'.imgPathTask,
                onTap: controller.actionDoTask,
              ),
            )
          : Container(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  _getItem(title: '牵头部门：', content: mod.mainDepartment!),
                  _getItem(title: '协同部门：', content: mod.aidDepartment!),
                  Text(
                    '要点批示：',
                    style: pfMediumStyle(
                      color: ColorsUtil.title,
                      fontSize: 14.sp,
                      height: 3,
                    ),
                  ),
                  Container(
                    width: Get.width,
                    padding: EdgeInsets.all(8.r),
                    decoration: BoxDecoration(
                      border: Border.all(
                        color: ColorsUtil.content,
                        width: 0.5,
                      ),
                      borderRadius: BorderRadius.circular(5.r),
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          mod.comment!,
                          style: pfMediumStyle(
                              color: ColorsUtil.content, fontSize: 13.sp),
                        ),
                        Container(
                          width: Get.width,
                          alignment: Alignment.centerRight,
                          child: Text(
                            '--' + mod.date!,
                            style: pfMediumStyle(
                                color: ColorsUtil.content, fontSize: 13.sp),
                          ),
                        )
                      ],
                    ),
                  )
                ],
              ),
            );
    });
  }

  Widget _getItem({
    required String title,
    required String content,
  }) {
    return Container(
      height: 50.r,
      decoration: const BoxDecoration(
          border: Border(bottom: BorderSide(color: ColorsUtil.separator))),
      child: Row(
        children: [
          Text(
            title,
            style: pfMediumStyle(color: ColorsUtil.title, fontSize: 15.sp),
          ),
          Text(
            content,
            style: pfMediumStyle(color: ColorsUtil.title, fontSize: 14.sp),
          ),
        ],
      ),
    );
  }
}
